package com.wysql.ascost.service.info;

import java.util.List;
import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.wysql.ascost.common.base.BaseService;
import com.wysql.ascost.common.support.ConvertUtil;
import com.wysql.ascost.mapper.info.InfoContractstoreDtlMapper;
import com.wysql.ascost.model.info.InfoContractstoreDtl;
import com.wysql.ascost.model.info.InfoContractstoreDtlExample;
import com.wysql.ascost.model.custom.Tablepar;
import com.wysql.ascost.util.SnowflakeIdWorker;
import com.wysql.ascost.util.StringUtils;

/**
 * 协议库存信息查询--明细 InfoContractstoreDtlService
 *
 * @author wysqlauto_自动生成
 * @Title: InfoContractstoreDtlService.java 
 * @Package com.wysql.ascost.service 
 * @email ${email}
 * @date 2025-03-10 16:00:43  
 **/
@Service
public class InfoContractstoreDtlService implements BaseService<InfoContractstoreDtl, InfoContractstoreDtlExample> {
    @Autowired
    private InfoContractstoreDtlMapper infoContractstoreDtlMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<InfoContractstoreDtl> list(Tablepar tablepar, InfoContractstoreDtl infoContractstoreDtl) {
        InfoContractstoreDtlExample testExample = new InfoContractstoreDtlExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(infoContractstoreDtl);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<InfoContractstoreDtl> list = infoContractstoreDtlMapper.selectByExample(testExample);
        PageInfo<InfoContractstoreDtl> pageInfo = new PageInfo<InfoContractstoreDtl>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        InfoContractstoreDtlExample example = new InfoContractstoreDtlExample();
        example.createCriteria().andIdIn(lista);
        return infoContractstoreDtlMapper.deleteByExample(example);


    }


    @Override
    public InfoContractstoreDtl selectByPrimaryKey(String id) {

        return infoContractstoreDtlMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(InfoContractstoreDtl record) {
        return infoContractstoreDtlMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(InfoContractstoreDtl record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return infoContractstoreDtlMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(InfoContractstoreDtl record, InfoContractstoreDtlExample example) {

        return infoContractstoreDtlMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(InfoContractstoreDtl record, InfoContractstoreDtlExample example) {

        return infoContractstoreDtlMapper.updateByExample(record, example);
    }

    @Override
    public List<InfoContractstoreDtl> selectByExample(InfoContractstoreDtlExample example) {

        return infoContractstoreDtlMapper.selectByExample(example);
    }


    @Override
    public long countByExample(InfoContractstoreDtlExample example) {

        return infoContractstoreDtlMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(InfoContractstoreDtlExample example) {

        return infoContractstoreDtlMapper.deleteByExample(example);
    }


}
